package org.bdware.doaclient;

import org.bdware.doip.core.doipMessage.DoipMessage;
import org.bdware.doip.core.doipMessage.DoipMessageFactory;
import org.bdware.irp.exception.IrpClientException;
import org.bdware.doip.core.utils.GlobalConfigurations;

public class ContractDOAClient extends DOAClient{

    public ContractDOAClient(String certPath, String certPWD, String userHandle, String LHSAddress) {
        super(certPath, certPWD, userHandle, LHSAddress);
    }

    public static ContractDOAClient getContractDOAClientForTest() {
        return new ContractDOAClient(GlobalConfigurations.JKSPath,GlobalConfigurations.JKSPassword,GlobalConfigurations.userID,GlobalConfigurations.IRSAddress);
    }

    public DoipMessage call(String doi,String elementID,byte[] args) throws IrpClientException {
        DoipMessage msg =
                new DoipMessageFactory.DoipMessageBuilder()
                        .createRequest(doi, "call")
                        .create();
        msg.header.parameters.addAttribute("elementID", elementID);
        msg.body.encodedData = args;
        return sendRaw(msg,getTargetRepoByDoID(doi));
    }

}
